#include "wx/wxprec.h"
#include "wx/xrc/xh_gauge.h"

IMPLEMENT_DYNAMIC_CLASS( wxGaugeXmlHandler, wxXmlResourceHandler )

wxGaugeXmlHandler::wxGaugeXmlHandler()
  : wxXmlResourceHandler() {
  XRC_ADD_STYLE( wxGA_HORIZONTAL );
  XRC_ADD_STYLE( wxGA_VERTICAL );
  XRC_ADD_STYLE( wxGA_PROGRESSBAR );
  XRC_ADD_STYLE( wxGA_SMOOTH ); // windows only
  AddWindowStyles();
}

wxObject *wxGaugeXmlHandler::DoCreateResource() {
  XRC_MAKE_INSTANCE( control, wxGauge )
  control->Create( m_parentAsWindow,
                   GetID(),
                   GetLong( wxT( "range" ), wxGAUGE_DEFAULT_RANGE ),
                   GetPosition(), GetSize(),
                   GetStyle(),
                   wxDefaultValidator,
                   GetName() );
  if( HasParam( wxT( "value" ) ) ) {
    control->SetValue( GetLong( wxT( "value" ) ) );
  }
  if( HasParam( wxT( "shadow" ) ) ) {
    control->SetShadowWidth( GetDimension( wxT( "shadow" ) ) );
  }
  if( HasParam( wxT( "bezel" ) ) ) {
    control->SetBezelFace( GetDimension( wxT( "bezel" ) ) );
  }
  SetupWindow( control );
  return control;
}

bool wxGaugeXmlHandler::CanHandle( wxXmlNode *node ) {
  return IsOfClass( node, wxT( "wxGauge" ) );
}
